<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
  <title>test微信分享</title>
  <script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  <!--<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>-->
  <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
  <!--<script src="./jquery-3.3.1.min.js"></script>-->
</head>
<body>
<div id="openLocation" style="width:100px;height: 100px; background:#ccc;margin:0 auto;"></div>
<script>
  $.ajax({
    type:'GET',
    url:'http://www.linqinghu.cn/my/public/api/share',
    dataType:'json',
    data:{url: encodeURIComponent(window.location.href)},
    success:function (res) {
      console.log(res);
      wx.config({
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: res.appId, // 必填，企业号的唯一标识，此处填写企业号corpid
        timestamp: res.timestamp, // 必填，生成签名的时间戳
        nonceStr: res.nonceStr, // 必填，生成签名的随机串
        signature: res.signature,// 必填，签名，见附录1
        jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ','openLocation']
      });
      wx.ready(function () {
        let shareObj = {
          title: '孝感瑞祥房产中介公司',
          desc: '诚信服务，专业二手房；欢迎你来',
          link: window.location.href,
          imgUrl: 'https://www.zetianhui.xyz/static/img/zth_logo.png',
        };
        //分享给朋友
        wx.onMenuShareAppMessage(shareObj);

        //分享到朋友圈
        wx.onMenuShareTimeline(shareObj);

        //分享到QQ
        wx.onMenuShareQQ(shareObj);
        document.querySelector('#openLocation').onclick = function () {
          wx.openLocation({
            latitude: 23.099994,
            longitude: 113.324520,
            name: 'TIT 创意园',
            address: '广州市海珠区新港中路 397 号',
            scale: 14,
            infoUrl: 'http://weixin.qq.com'
          });
        };
      })
    }
  })
</script>
</body>
</html>